var domain = document.domain;
if(domain.indexOf("adream.org") != -1) {
	//设置document.domain解决跨域问题
	document.domain = "adream.org";	
}

$.fn.serializeJson = function () {
    var serializeObj = {};
    $(this.serializeArray()).each(function () {
        if(serializeObj[this.name]!=undefined){
            if($.isArray(serializeObj[this.name])){
                serializeObj[this.name].push(this.value);
            }else{
                serializeObj[this.name]=[serializeObj[this.name],this.value];
            }
        }else{
            serializeObj[this.name]=this.value;
        }
    });
    return serializeObj;
};

function getRootPath() {
    //获取当前网址，如： http://localhost:8083/proj/meun.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： proj/meun.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPath = curWwwPath.substring(0, pos);
    //获取带"/"的项目名，如：/proj
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    return (localhostPath + projectName);
}

function getHostPath() {
	//获取当前网址，如： http://localhost:8083/proj/meun.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： proj/meun.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPath = curWwwPath.substring(0, pos);
    return localhostPath;
}

function formatUndefined(data) {
	return data == undefined ? "" : data;
}

String.prototype.startWith = function(str){
	if(str == null || str== "" || this.length== 0 || str.length > this.length){
		return false;
	} 
	if(this.substr(0,str.length) == str){
		return true;
	}else{
		return false;
	}       
	return true; 
};

String.prototype.endWith = function(str){
	 if(str==null || str=="" || this.length == 0 ||str.length > this.length){	
      return false;
	 }
	 if(this.substring(this.length - str.length)){
		 return true;
	 }else{
		 return false;
	 }
	 return true;
};